package com.lvy.hczn.front.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lvy.hczn.front.common.core.text.Convert;
import com.lvy.hczn.front.system.domain.business.DataException;
import com.lvy.hczn.front.system.mapper.DataExceptionMapper;
import com.lvy.hczn.front.system.service.DataExceptionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 出入库异常主表业务逻辑
 *
 * @author yw
 * @date 2023-07-04 16:32:14
 **/
@Service
@Slf4j
public class DataExceptionServiceImpl extends ServiceImpl<DataExceptionMapper, DataException> implements DataExceptionService {

    @Autowired
    private DataExceptionMapper dataExceptionMapper;

    /**
     * 查询
     *
     * @param id 主键
     * @return
     */
    @Override
    public DataException selectDataExceptionById(String id) {
        return dataExceptionMapper.selectById(id);
    }

    /**
     * 查询列表
     *
     * @param dataException
     * @return
     */
    @Override
    public List<DataException> selectDataExceptionList(DataException dataException) {
        return dataExceptionMapper.selectDataExceptionList(dataException);
    }

    /**
     * 新增
     *
     * @param dataException
     * @return 结果
     */
    @Override
    public int insertDataException(DataException dataException) {
        return dataExceptionMapper.insert(dataException);
    }

    /**
     * 修改
     *
     * @param dataException
     * @return 结果
     */
    @Override
    public int updateDataException(DataException dataException) {
        return dataExceptionMapper.updateById(dataException);
    }

    /**
     * 批量删除
     *
     * @param ids 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteDataExceptionByIds(String ids) {
        String[] idArray = Convert.toStrArray(ids);
        for (String id : idArray) {
            dataExceptionMapper.deleteById(id);
        }
        return idArray.length;
    }

    /**
     * 删除信息
     *
     * @param id 主键
     * @return 结果
     */
    @Override
    public int deleteDataExceptionById(String id) {
        return dataExceptionMapper.deleteById(id);
    }
}
